import numpy as np

if __name__ == '__main__':
    vector1 = np.array([2, 1])
    vector2 = np.array([1, 2])

    # 计算向量的内积
    dot = np.dot(vector1, vector2)

    # 计算向量的模
    vector1_norm = np.linalg.norm(vector1)
    vector2_norm = np.linalg.norm(vector2)

    # 利用公式计算余弦值
    cos_angle = dot / vector1_norm / vector2_norm
    print(cos_angle)
